/*
 * @Author: nns4
 * @Date: 2020-02-27 17:33:37
 * @LastEditors: nns4
 * @FilePath: /citciWechartShop/src/libs/regular.js
 * @Description: 正则验证
 */

const regulars = {
    phone: /^1[3456789]\d{9}$/, //手机号
    positiveInteger: /^[1-9]\d*$/, //正整数
    positiveNumber: /^\d*\.?\d+$/ // 正数
}


export default ((type, value) => {
    /**
     * @description: 
     * @param {type:正则类型, value:正则值} 
     * @return: 
     */
    return new Promise((resolve, reject) => {
        if (regulars[type].test(value)) {
            return resolve(true)
        } else {
            return reject(true)
        }
    })
});